<template>
	<view class="home">
		<navbar></navbar>
		<view class="songlist">
			<uni-list>
				<uni-list-item v-for="(item,index) in playlist" class="songlist-item" title="" note="">
					<view class="img">
						<image :src="item.coverImgUrl" mode=""></image>
					</view>
					<view class="text">
						<text class="title">
							{{item.name}}
						</text>
					</view>
				</uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: "",
				playlist:[]
			}
		},
		onLoad() {
			var that = this
			uni.getStorage({
				key: 'user',
				success: function(res) {
					that.user = res.data
					that.getSongList()
				}
			})

		},
		methods: {
			getSongList() {
				uni.request({
					url: this.$url + 'user/playlist?uid=' + this.user.account.id,
					method: "GET",
					success: (res) => {
						this.playlist = res.data.playlist
						console.log(res)
					}
				})
			}
		}
	}
</script>

<style lang="stylus">
	.home {
		.songlist {
			&-item {
				display flex
				.img {
					width 70px
					height 70px

					image {
						width 100% 
						height 100%
					}
				}
				.text{
					font-size 15px
				}
			}
		}
	}
</style>
